# -*- coding : utf-8-*-
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin

from .models import (User, UserExtend)


# 将用户扩展表加入到Admin的User表中，内联
class UserExtendInline(admin.StackedInline):
    model = UserExtend
    max_num = 1
    can_delete = False


# UserGeneralTableAdmin总表
class UserGeneralTableAdmin(UserAdmin):
    inlines = [UserExtendInline]
    list_display = ['username', 'email']
    # 'telephone', 'isDelete', 'isValid',
    #                 'roleType', 'userLevel', 'createTime', 'updateTime', 'lastLoginTime']
    search_fields = ['username']
    list_filter = ['username']
    list_per_page = 10


# 去掉User表在admin中的注册
admin.site.unregister(User)
admin.site.register(User, UserGeneralTableAdmin)



